//会员登录状态(token)的store

import { defineStore } from "pinia"
import { ref } from "vue"


export const useToken = defineStore("token", ()=>{
    //定义状态数据(state)
    const token = ref(null)

    //修改token的方法(action)
    const updateToken = (val:any)=>{
        token.value = val
    }

    //移除token的方法(action)
    const removeToken = ()=>{
        token.value = null
    }

    //以对象形式返回
    return { token, updateToken, removeToken }
},{
    persist:{
        key:"token",
        storage:sessionStorage
    }
})
